<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Meeting rooms overview</title>
    </h:head>
    <h:body>
        <h:form>
            <p:toolbar>
                <p:commandButton type="push" value="New meeting room" image="ui-icon-document"
                                 action="#{roomsBackingBean.newRoom}"
                                 update="table"/>
            </p:toolbar>

            <p:spacer height="10px" />

            <p:dataTable id="table" var="row" value="#{roomsBackingBean.roomsDao.allRooms}"
                         selection="#{roomsBackingBean.selectedRoom}"
                         selectionMode="single"
                         update="details">
                <p:column resizable="1">
                    <f:facet name="header">Room</f:facet>
                    #{row.name}
                </p:column>
                <p:column resizable="true">
                    <f:facet name="header">Capacity</f:facet>
                    #{row.capacity}
                </p:column>
                <p:column>
                    <f:facet name="header">&nbsp;</f:facet>
                    <h:link outcome="reservations" value="Reservations" />
                </p:column>
            </p:dataTable>

            <p:spacer height="10px" />

            <p:panel id="details" header="Details">
                <h:panelGrid columns="2" rendered="#{roomsBackingBean.roomSelected}">
                    <h:outputLabel for="naam" value="Zaal:" />
                    <h:inputText id="naam" value="#{roomsBackingBean.selectedRoom.name}"/>
                    <h:outputLabel for="capaciteit" value="Capaciteit" />
                    <h:inputText id="capaciteit" value="#{roomsBackingBean.selectedRoom.capacity}"/>
                    <h:outputText value="&nbsp;"/>
                    <p:commandButton action="#{roomsBackingBean.updateRoom}" update="table"
                                     value="Save" />
                </h:panelGrid>
            </p:panel>
        </h:form>
    </h:body>
</html>
